<?php

/**
 * This is the model class for table "ParamModel".
 *

 *
 * The followings are the available model relations:
 */
class ParamModel extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return BTrademethod the static model class
	 */
	public $keyname='';
	public $displayname='';
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	
	public function getListData()
	{
		$results = array();
		$models = $this->findAll(array('order'=>$this->displayname,));
	    foreach ($models as $key => $value) {
	    	$results[$value[$this->keyname]] = $value[$this->displayname];
	    }
	    return $results;
	}
	
	public function getNameByKey($keyValue)
	{
		return $this->findByAttributes(array($this->keyname=>$keyValue,))->getAttribute($this->displayname);
	}

}